package com.hbnu.dao;

import com.hbnu.pojo.Order;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrdersDao {
    @Select("select * from tb_order")
    List<Order> getOrders();

    @Select("select * from tb_order where id = #{id}")
    Order getOrderById(int id);

    @Delete("delete from tb_order where id = #{id}")
    int deleteOrderById(int id);

    @Insert("insert into tb_order(door_id,order_no,order_type,pnum,cashier,order_time,pay_time,pay_type,price) values (#{door_id},#{order_no},#{order_type},#{pnum},#{cashier},now(),DATE_ADD(now(), interval 30 minute),#{pay_type},#{price})")

    int addOrder(Order order);

    @Update("update tb_order set door_id=#{door_id},order_no=#{order_no},order_type=#{order_type},pnum=#{pnum},cashier=#{cashier},order_time=#{order_time},pay_time=#{pay_time},pay_type=#{pay_type},price=#{price} where id=#{id}")
    int updateOrder(Order order);
}
